package com.ourcraft.informationcollectionsystem.controller.company;

import com.ourcraft.informationcollectionsystem.service.company.companyDataQuery.CompanyDataQueryService;
import com.ourcraft.informationcollectionsystem.utils.response.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Map;

/**
 * CompanyDataQueryController handles company's dataReportForm-query-related operations.
 *
 * @author Liu Yiming
 * @since 2023-11-04
 */
@RequestMapping("enterprise/dataQuery/")
@RestController
@CrossOrigin()
public class CompanyDataQueryController {

    @Autowired
    CompanyDataQueryService companyDataQueryService;

    /**
     * Retrieves information of all forms out by user ID.
     *
     * @param userId The ID of the user.
     * @return information of all forms.
     */
    @GetMapping("allQueryDataInfo")
    public Result<ArrayList<Map<String, Object>>> getAllQueryDataInfo(@RequestParam int userId)
    {
        ArrayList<Map<String, Object>> result = companyDataQueryService.getAllQueryDataInfo(userId);
        return Result.success(result);
    }

    /**
     * Retrieves information of a form out by form ID.
     *
     * @param formID The ID of the form.
     * @return information of the forms.
     */
    @GetMapping("queryFormInfo")
    public Result<Map<String, Object>> getQueryFormInfo(@RequestParam int formID)
    {
        Map<String, Object> result = companyDataQueryService.getQueryFormInfo(formID);
        return Result.success(result);
    }
}
